package edu.hit.pact.pgse.client.database;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;

public class SourceDao {
	
	public List<Source> querySource() {
		Session session = null;
		Query query = null;
		List<Source> sl = null;
		
		try {
			System.out.println("------------------------------------------------------------");
			session = HibernateSessionFactory.getSession();
			System.out.println("------------------------------------------------------------");
			query = session.createQuery("from edu.hit.pact.pgse.client.database.Source s order by s.sourceid");
			sl = query.list();
			System.out.println("------------------------------------------------------------");
		} catch (HibernateException e) {
			System.out.println("Got Exception while query source");
			e.printStackTrace();
		} finally {
			try {
				HibernateSessionFactory.closeSession();
			} catch (HibernateException e) {
				System.out.println("Got Exception while close session of query source");
				e.printStackTrace();
			}
		}
		return sl;
	}

}
